<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@ include file="/commons/pages/taglibs.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>${naviString}</title>
<link href="${ctx}/commons/styles/themes/blue/styles/style.css" rel="stylesheet" type="text/css" />
<link href="${ctx}/commons/scripts/jquery-ui/themes/redmond/jquery-ui.custom.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div align="center">
  <div align="center" style="width: 99%">
    <div align="left" class="nav">${naviString}</div>
    <fieldset>
    <legend>快速搜索</legend>
    <html-el:form action="/manager/ProductInfo.do">
      <html-el:hidden property="method" value="list" />
      <html-el:hidden property="mod_id" />
      产品一级分类：
      <html-el:select property="type1_id" styleId="type1_id" style="width:120px">
      	<html-el:option value="">请选择...</html-el:option>
      	<c:forEach var="p_cur" items="${firstTypeList}">
      	  <html-el:option value="${p_cur.dictionary_value}">${p_cur.dictionary_desc_cn}</html-el:option>
      	</c:forEach>
      </html-el:select>
      &nbsp;
      产品二级分类：
      <html-el:select property="type2_id" styleId="type2_id" style="width:120px">
        <html-el:option value="">请选择...</html-el:option>
      </html-el:select>
      &nbsp;
      是否已删除:
      <html-el:select property="is_del">
        <html-el:option value="0">未删除</html-el:option>
        <html-el:option value="1">已删除</html-el:option>
      </html-el:select>
      &nbsp;
      <html-el:submit value="快速搜索" styleClass="ui-state-default ui-corner-all" style="cursor:pointer;" />
    </html-el:form>
    </fieldset>
    <%@ include file="/commons/pages/messages.jsp" %>
    <br/>
    <form id="listForm" name="listForm" method="post" action="ProductInfo.do?method=delete">
      <div style="text-align: left">
        <input type="button" name="delete" id="delete" value="删除所选" onclick="this.form.action += '&' + $('#bottomPageForm').serialize();confirmDeleteAll(this.form);" class="ui-state-default ui-corner-all" style="cursor:pointer;" />
        <input type="button" name="add" id="add" value="添加" onclick="location.href='ProductInfo.do?method=add&mod_id=${hf.map.mod_id}&type1_id_=${hf.map.type1_id_}&type2_id_=${hf.map.type2_id_}&from=${hf.map.from}';" class="ui-state-default ui-corner-all" style="cursor:pointer;" />
        <input type="hidden" name="method" id="method" value="delete" />
        <input type="hidden" name="mod_id" id="mod_id" value="${hf.map.mod_id}" />
      </div>
      <br/>
      <table width="100%" border="0" cellpadding="0" cellspacing="1" class="datagrid">
        <tr>
          <th width="5%" nowrap="nowrap"><input name="chkAll" type="checkbox" id="chkAll" value="-1" onclick="checkAll(this);" /></th>
          <th nowrap="nowrap">产品名称</th>
          <th width="15%" nowrap="nowrap">一级分类</th>
          <th width="15%" nowrap="nowrap">二级分类</th>
          <th width="10%" nowrap="nowrap">产品型号</th>
          <th width="8%" nowrap="nowrap">产品尺寸</th>
          <th width="8%" nowrap="nowrap">是否新品</th>
          <th width="8%" nowrap="nowrap">是否推荐产品</th>
          <th width="5%" nowrap="nowrap">改</th>
          <th width="5%" nowrap="nowrap">删</th>
        </tr>
        <c:forEach var="cur" items="${entityList}" varStatus="vs">
          <tr>
            <td align="center"><c:if test="${cur.is_del eq 0}"><input name="pks" type="checkbox" id="pks" value="${cur.product_id}" /></c:if>
              <c:if test="${cur.is_del eq 1}"><input name="pks" type="checkbox" id="pks" value="${cur.product_id}" disabled="disabled" /></c:if></td>
            <td align="left"><a href="ProductInfo.do?method=view&mod_id=${hf.map.mod_id}&product_id=${cur.product_id}">${cur.product_name}</a></td>
            <td align="left">${cur.map.type1_name}</td>
            <td align="left">${cur.map.type2_name}</td>
            <td align="center">${cur.product_model}</td>
            <td align="center">${cur.product_size}</td>
            <td align="center"><c:if test="${cur.is_new eq 1}" var="is_new_">是</c:if ><c:if test="${!is_new_}">否</c:if></td>
            <td align="center"><c:if test="${cur.is_recommend eq 1}" var="is_recommend_">是</c:if ><c:if test="${!is_recommend_}">否</c:if></td>
            <td align="center"><c:if test="${cur.is_del eq 0}"><span style="cursor:pointer;" onclick="confirmUpdate(null, 'ProductInfo.do', 'product_id=${cur.product_id}&' + $('#bottomPageForm').serialize())">改</span></c:if>
              <c:if test="${cur.is_del eq 1}"><span style="color: #ccc">改</span></c:if>
            </td>
            <td align="center"><c:if test="${cur.is_del eq 0}"><span style="cursor:pointer;" onclick="confirmDelete(null, 'ProductInfo.do', 'product_id=${cur.product_id}&' + $('#bottomPageForm').serialize())">删</span></c:if>
              <c:if test="${cur.is_del eq 1}"><span style="color: #ccc">删</span></c:if>
            </td>
          </tr>
        </c:forEach>
      </table>
    </form>
    <form id="bottomPageForm" name="bottomPageForm" method="post" action="ProductInfo.do">
      <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td height="40" align="center"><script type="text/javascript" src="${ctx}/commons/scripts/pager.js">;</script>
            <script type="text/javascript">
            var pager = new Pager(document.bottomPageForm, ${hf.map.pager.recordCount}, ${hf.map.pager.pageSize}, ${hf.map.pager.currentPage});
            pager.addHiddenInputs("method", "list");
            pager.addHiddenInputs("mod_id", "${hf.map.mod_id}");
            pager.addHiddenInputs("type1_id", "${hf.map.type1_id}");
            pager.addHiddenInputs("type2_id", "${hf.map.type2_id}");
            pager.addHiddenInputs("is_del", "${hf.map.is_del}");
            document.write(pager.toString());
            </script>
          </td>
        </tr>
      </table>
    </form>
  </div>
</div>
<script type="text/javascript" src="${ctx}/commons/scripts/jquery.js"></script>
<script type="text/javascript" src="${ctx}/commons/scripts/jquery-ui/ui/minified/jquery-ui.custom.min.js"></script>
<script type="text/javascript" src="${ctx}/commons/scripts/rowEffect.js"></script>
<script type="text/javascript">//<![CDATA[
$(document).ready(function(){
	$("input[type='submit'],input[type='button']").css("border", "1px solid");
	
	var f = document.forms[0];

	if($("#type1_id").val() != ""){
		$("#type1_id").change();
	}
});

$("#type1_id").change(function(){
	var option = "<option value=''>请选择...</option>";
	
	if($(this).val() != ""){
		$.ajax({
			async: false,
			type: "POST",
			url: "ProductInfo.do",
			data: "method=getProductType2&type1_id=" + $(this).val(),
			dataType: "json",
			error: function(request, settings) {/*alert("数据请求失败！"); */},
			success: function(data) {
				for(var i=0;i<data.length;i++){
					var id = data[i].id;
					var name = data[i].name;
	
					option += "<option value="+ id +">" + name + "</option>";
				}
			}
		});
	}

	$("option","#type2_id").remove();
	$("#type2_id").append(option);

	if("" != "${hf.map.type2_id}"){
		$("#type2_id").val("${hf.map.type2_id}");
	}
});
//]]></script>
</body>
</html>
